const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('Who are you?', name => {
console.log(`Hey there ${name}!`);
readline.close();
});
//Make sure you have Node and NPM installed
//Run "npm install prompt-sync" in the terminal
const prompt = require('prompt-sync')();
const name = prompt('What is your name?');
console.log(`Hey there ${name}`);
--------------- easiest method I found---------------------------
Run npm install prompt-sync in the terminal
const prompt = require('prompt-sync')();
var name = prompt('what is your name?');
console.log(name);
--------------------------------------------------------------